package org.renhj.loadbalance.impl;

import org.renhj.consumer.RpcClient;
import org.renhj.loadbalance.AbstractLoadBalance;
import org.renhj.loadbalance.LoadBalance;

import java.util.List;
import java.util.Random;

public class RandomLoadBalance extends AbstractLoadBalance {
    @Override
    public RpcClient doSelect(List<RpcClient> clients) {
        int length = clients.size();
        return clients.get(new Random().nextInt(length));
    }
}
